package com.ymatou.iapi.couponservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.couponservice.parameter.GetUserCouponInfosByBatchBean;
import com.ymatou.iapi.couponservice.service.GetUserCouponInfosByBatchCall;
import com.ymatou.iapi.m.couponservice.parameter.SellerCreateBatchBean;
import com.ymatou.promotion.api.parameter.CouponBatchBean;
import com.ymatou.promotion.api.service.CreateSellerCouponCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.business.service.CouponManageCallService;
import com.ymttest.business.service.CouponServiceCallService;
import com.ymttest.business.service.CouponServiceMCallService;
import com.ymttest.utils.EnvSetup;
/**
*获取用户指定批次的优惠券信息
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetUserCouponInfosByBatch{
	private static GetUserCouponInfosByBatchBean getusercouponinfosbybatchBean;
	private static GetUserCouponInfosByBatchCall getusercouponinfosbybatchCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取用户指定批次的优惠券信息");
	}

	@Before
	public void caseUp() {
		getusercouponinfosbybatchBean=new GetUserCouponInfosByBatchBean();
		getusercouponinfosbybatchCall=new GetUserCouponInfosByBatchCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getusercouponinfosbybatchCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserCouponInfosByBatch_001() {
		Logger.start(true,"获取用户指定批次的优惠券信息");
		try {
			
			int userId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
			CouponServiceMCallService couponCallService = new CouponServiceMCallService();
			
			// 商家优惠券
			SellerCreateBatchBean couponBatchBean = couponCallService.setDefaultSellerCreateBatchBean();
			String batchCode1 = couponCallService.SellerCreateBatch(couponBatchBean).getBatchCode();
			String couponCode = new CouponServiceCallService().receiveCouponInfo(batchCode1, userId);

			getusercouponinfosbybatchBean.setUserId(userId);
			getusercouponinfosbybatchBean.setBatchCode(batchCode1);
			getusercouponinfosbybatchBean.setAppId("aas");
			getusercouponinfosbybatchBean.setRequestId("sdgfdgdgfdgf");
			
			getusercouponinfosbybatchCall.setData(getusercouponinfosbybatchBean);
			getusercouponinfosbybatchCall.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}